<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户管理</title>
    <link rel="import" href="../../../includes/baseInclude.html">
    <style type="text/css">
        .ui-jqgrid tr.jqgrow td { white-space: normal !important; height:auto; }
        /*jqgrid首行背景色*/
        .ui-th-column{
            background-color:#ffffff !important;
            text-align: center !important;
            /*border: none !important;*/
        }
        /*表格去除竖线*/
         table.table-bordered td {
             border: none !important;
             text-align: center !important;
         }
         /*checkbox前面的*/
       #userTableList_rn{
           width: 29px !important;
       }
        .ui-jqgrid-bdiv{
            border: none !important;
        }
        .ui-pg-input{
            border: none !important;
        }
        .ui-jqgrid-hbox{
            border: none !important;
        }
    
    </style>
</head>
<body ng-app="dutyTableApp" ng-controller="dutyTableCtrl">
<div>
    <div style="margin-left:15px;margin-top:10px;">
        <input type="radio" ng-model="normalDuty" name="normalDuty" value="正常班" />
        <span>正常班</span>
        <input type="radio" ng-model="normalDuty" name="morningDuty" value="早班" />
        <span>早班</span>
        <input type="radio" ng-model="normalDuty" name="eveningDuty" value="晚班" />
        <span>晚班</span>
    </div>
    <div class="pd-15" style="overflow-y:hidden;">
        <div style="clear: both;"></div>
        <div  style="width: 100%;height:auto;overflow-x:hidden;" class="jqGrid_wrapper">
            <table id="dutyTableList" style="overflow-x:hidden;"></table>
            <div id="dutyTableListPager"></div>
        </div>
    </div>
    <button type="button" ng-click="save()" style="float:right;margin-right:10px;" class="btn btn-secondary radius">确定</button>
</div>
<script type="text/javascript" src="../js/layer.js"></script>
<script type="text/javascript" src="../../../js/base/jqGrid.js"></script>
<script type="text/javascript" src="../../../js/libs/gridUtil.js"></script>
<script src="../js/jquery.params.js"></script>
<script>
    //angularjs post 提交时HTTP头设置
    var transform = function (data) {
        return $.param(data);
    }, postCfg = {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
        },
        transformRequest: transform
    };
    var app = angular.module('dutyTableApp',[]);
    app.controller('dutyTableCtrl',function($scope,$http){
    	$scope.normalDuty = "正常班";
        /*选中删除 checkBox*/
        function getSelectedIds(){
            $scope.selectedIds = $("#dutyTableList").jqGrid("getGridParam", "selarrrow");
            return $scope.selectedIds;
        };
        //list拼接
        function stitchingParameter(objectParam,listParam,listName,notColnumName){
        	if(listName==undefined){
        		listName = '';
        	}
        	for(var i = 0;i<listParam.length;i++){
        		for(var object in listParam[i]){
        			if(listParam[i][object] == null||notColnumName && notColnumName.indexOf(object)!=-1) continue;
        			objectParam[listName+'['+i+'].'+object] = listParam[i][object];
        		}
        	}
        	return objectParam;
        }
        //确定按钮操作
        $scope.getDate = $.query.get("date");
        $scope.save = function(){
        	getSelectedIds();
        	var i = 0;
        	var objDatas = [];
            angular.forEach($scope.selectedIds,function(s_data,s_index,s_array){
        		var obj = {
        				'person.id':s_data,
        				'time':$scope.getDate,
        				'normal':$scope.normalDuty,
        		};
        		objDatas.push(obj);
        		i++;
        	});
            var da = {};
            var data = stitchingParameter(da,objDatas,"normal");
        	$http.post('/watchArrangements/addBatch',data,postCfg)
        	     .success(function(data){
        	    	 
        	     })
        };
    });
</script>
<script>
    $(document).ready(function(){
        $("#dutyTableList").jqGridFunction({
            url:'/people/findPeople',
            dataType:'json',
            postData:{},
            styleUI:'Bootstrap',
            autowidth:true,
            viewrecords:true,
            shrinkToFit:true,
            rowList:[10,20,50,100],
            colNames:['主键','姓名','P13帐号','手机号码','部门','职位','状态'],
            colModel:[{name:'id',key:true,hidden:true},
                {name:'name',width:100},
                {name:'account',sortable:true},
                {name:'phone',width:'200px',sortable:true},
                {name:'department',sortable:true},
                {name:'job',sortable:true},
                {name:'state',sortable:true}
            ],
            height:$(document).height()-$("#manage-area-title").height()-190,
            rownumbers: true, // 显示行号
            multiselect:true

        });
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width();
            $("#dutyTableList").setGridWidth(width);
        });
		function operatFormatter(cellvalue, options, rowObject){
				var operateHtml = "";
				    operateHtml +='<a title="编辑" href="javascript:layer_shows('+rowObject.id+',1)" class="ml-5" style="text-decoration: none"><i class="Hui-iconfont">&#xe6df;</i></a>';
				    operateHtml +='<a title="删除" href="javascript:deleUser('+rowObject.id+')"  class="ml-5" style="text-decoration: none"><i class="Hui-iconfont">&#xe6e2;</i></a>';
				return operateHtml;
	    };
    });
</script>
</body>
</html>